//
//  RegistPassWordViewController.m
//  Consume100
//
//  Created by eliot on 16/3/22.
//  Copyright © 2016年 aleven. All rights reserved.
//

#import "RegistPassWordViewController.h"
#define kAlphaNum @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"

@interface RegistPassWordViewController ()<UITextFieldDelegate>

@property (weak, nonatomic) IBOutlet UITextField *submitTextField;

@property (weak, nonatomic) IBOutlet UITextField *enterTextField;


@property (weak, nonatomic) IBOutlet UIButton *registBtn;

@property (weak, nonatomic) IBOutlet UIButton *serviceAgreementBtn;


@end

@implementation RegistPassWordViewController

+(RegistPassWordViewController*)CreatRegistPassWordViewController{
    
    UIStoryboard *story=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
    RegistPassWordViewController *password=[story instantiateViewControllerWithIdentifier:@"RegistPassWordViewController"];
    return password;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"注册";
    self.view.backgroundColor = [UIColor colorWithRed:237/255.0 green:237/255.0 blue:237/255.0 alpha:1];
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],NSForegroundColorAttributeName:[UIColor whiteColor]}];
    self.registBtn.backgroundColor = [UIColor colorWithRed:255/255.0 green:88/255.0 blue:88/255.0 alpha:1];
    self.registBtn.layer.cornerRadius = 4;
    self.registBtn.layer.masksToBounds = YES;
    self.enterTextField.keyboardType = UIKeyboardTypeASCIICapable;
    self.submitTextField.keyboardType = UIKeyboardTypeASCIICapable;
    self.enterTextField.delegate = self;
    self.submitTextField.delegate = self;
    
    
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],NSForegroundColorAttributeName:[UIColor whiteColor]}];
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
    self.navigationController.navigationBar.translucent = NO;
    
}

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    NSCharacterSet *cs;
    cs = [[NSCharacterSet characterSetWithCharactersInString:kAlphaNum] invertedSet];
    
    NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""]; //按cs分离出数组,数组按@""分离出字符串
    
    
    BOOL canChange = [string isEqualToString:filtered];
    
    
    return canChange;
}

//点击空白处收回键盘
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    [self.enterTextField resignFirstResponder];
    [self.submitTextField resignFirstResponder];
}


- (void)dismiss {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


//点击注册按钮
- (IBAction)clickRegistBtn:(id)sender {
    
}

//点击服务协议按钮
- (IBAction)clickServiceAgreementBtn:(id)sender {
    
}



/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
